/*
 * @Copyright Reserved By Janusec (https://www.janusec.com/).
 * @Author: U2
 * @Date: 2018-07-14 16:38:30
 * @Last Modified: U2, 2018-07-14 16:38:30
 */

package gateway

import (
	"bytes"
	"html/template"
	"net/http"

	"github.com/Janusec/janusec/models"
)

// GenerateBlockPage ...
func GenerateBlockPage(w http.ResponseWriter, hitInfo *models.HitInfo) {
	tmpl := template.New("Janusec")
	tmpl, _ = tmpl.Parse(blockHTML)
	w.WriteHeader(403)
	tmpl.Execute(w, hitInfo)
}

// GenerateBlockConcent ...
func GenerateBlockConcent(hitInfo *models.HitInfo) []byte {
	tmpl := template.New("Janusec")
	tmpl, _ = tmpl.Parse(blockHTML)
	buf := new(bytes.Buffer)
	tmpl.Execute(buf, hitInfo)
	return buf.Bytes()
}

var blockHTML = `<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>
<a href="http://www.janusec.com" target="_blank">
<img src="" 
alt="Janusec Application Gateway" 
title="Janusec Application Gateway, an application security solution which provides WAF (Web Application Firewall), CC attack defense, unified web administration, certificate protection, and scalable load balancing." >
</a>
</h1></center>
<hr>
<center>Reason: {{.VulnName}}, Policy ID: {{.PolicyID}}, by Janusec Application Gateway</center>
</body>
</html>
`
